package com.yumis.service.common.vo;

import com.yumis.service.common.enums.HttpState;
import lombok.Data;

import java.io.Serializable;

/**
 * @描述: 封装返回基类
 */

@Data
public class Response<T> implements Serializable {

    //状态码
    private int code;
    //消息描述
    private String message;
    //返回data实体
    private T data;

    public Response(int code, String message, T data){
        this.code = code;
        this.message = message;
        this.data = data;
    }


    public static <T> Response<T> buildResponse(HttpState enums){
        return new Response<>(enums.code(), enums.message(),null);
    }

    public static <T> Response<T> buildResponse(HttpState enums, T data){
        return new Response<>(enums.code(), enums.message(), data);
    }

}
